import request from '@/utils/request'
import { praseStrZero } from '@/utils/ruoyi'
import { downFile } from '@/utils/request'

// 查询用户列表
export function listUser(query) {
  return request({
    url: '/system/user/list',
    method: 'get',
    params: query
  })
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: '/system/user/' + praseStrZero(userId),
    method: 'get'
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/system/user/add',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: '/system/user/edit',
    method: 'put',
    data: data
  })
}

// 删除用户
export function delUser(userId) {
  return request({
    url: '/system/user/' + userId,
    method: 'delete'
  })
}

// 导出用户
export async function exportUser(query) {
  // return request({
  //   url: '/system/User/export',
  //   method: 'get',
  //   params: query
  // })
  await downFile('/system/user/export', { ...query })
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/system/user/resetPwd',
    method: 'put',
    data: data
  })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/system/user/changeStatus',
    method: 'put',
    data: data
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/system/user/profile',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/system/user/profile/avatar',
    method: 'post',
    data: data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// 下载用户导入模板
export function importTemplate() {
  return request({
    url: '/system/user/importTemplate',
    method: 'get',
    responseType: 'blob' //1.首先设置responseType对象格式为 blob:
  })
}
// 查询风向坐标
export function getSheetTest2(data) {
  return request({
    url: '/system/sheetTest2/list',
    method: 'post',
    params: data
  })
}

// 查询风向坐标DBS
export function windDataDBS(data) {
  return request({
    url: '/system/windDataDBS/list',
    method: 'post',
    data
  })
}
// 查询风向坐标PPI
export function windDataPPI(data) {
  return request({
    url: '/system/windDataPPI/list',
    method: 'post',
    data
  })
}
// 查询历史风向坐标PPI
export function historyList(data) {
  return request({
    url: '/system/windDataPPI/historyList',
    method: 'post',
    data
  })
}
// 下载风向坐标PPI
export function exportDataPPI(data) {
  return request({
    url: '/system/windDataPPI/export',
    method: 'post',
    responseType: 'blob',
    data
  })
}
// 查询表名
export function tableQuery(data) {
  return request({
    url: '/system/tableQuery/list',
    method: 'post',
    data
  })
}
// 查询表名(表内)
export function getTableList(data) {
  return request({
    url: '/system/tableMetadata/list',
    method: 'post',
    data
  })
}
// 查询表名
export function windlidarStatus(data) {
  return request({
    url: '/system/windLidarStatus/status',
    method: 'get',
  })
}


// 报警配置查询
export function getConfig() {
  return request({
    url: '/system/config/getConfig',
    method: 'get',
  })
}
// 报警配置修改
export function putConfig(data) {
  return request({
    url: '/system/config/putConfig',
    method: 'put',
    data
  })
}

// 报警记录列表
export function alarmRecord(data) {
  return request({
    url: '/system/alarmRecord/list',
    method: 'post',
    data
  })
}

// 雷达初始化
export function windLidarInit() {
  return request({
    url: '/system/windLidarInit/init',
    method: 'post',
  })
}
// 停止采集
export function stopWindLidar() {
  return request({
    url: '/system/windLidarInit/stop',
    method: 'post',
  })
}
// 开始采集
export function startWindLidar(data) {
  return request({
    url: '/system/windLidarInit/start',
    method: 'post',
    data
  })
}
// 雷达基础信息查询服务
export function windLidarInfo() {
  return request({
    url: '/system/windLidarInfo/info',
    method: 'get',
  })
}

//回波图信息
export function ppiLr(data) {
  return request({
    url: '/system/b_cdwl_ppi_lr/list',
    method: 'post',
    data
  })
}


// 报警记录 (状态列表列表)
export function getAlarmList(data) {
  return request({
    url: '/system/alarmList/list',
    method: 'post',
    data
  })
}
// 报警记录 (状态列表新增)
export function addAlarmList(data) {
  return request({
    url: '/system/alarmList/add',
    method: 'post',
    data
  })
}
// 报警记录 (状态列表删除)
export function delAlarmList(data) {
  return request({
    url: '/system/alarmList',
    method: 'delete',
  })
}